package com.shop.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.shop.mapper.CategoryMapper;
import com.shop.mapper.CategoryMapperCustom;
import com.shop.pojo.Category;
import com.shop.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 商品分类  服务实现类
 * </p>
 *
 * @author Administrator
 * @since 2020-10-31
 */
@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements CategoryService {

    @Autowired
    private CategoryMapperCustom categoryMapperCustom;

    @Override
    public List<Category> queryAllRootCats() {
        QueryWrapper<Category> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq(Category.TYPE,1);
        return this.list(queryWrapper);
    }

    @Override
    public List getSubList(Integer rootID) {
        return categoryMapperCustom.getSubCatList(rootID);
    }

    @Override
    public List querySixNewItemsLazy(Integer roodId) {
        Map map = new HashMap();
        map.put("rootCatId",roodId);
        return categoryMapperCustom.querySixNewItemsLazy(map);
    }
}
